package com.jincp.image.pick;

//import com.pbq.imagepicker.bean.Document;

import com.jincp.image.pick.bean.Document;

import java.util.ArrayList;
import java.util.List;

/**
 * ================================================
 * 作    者：jeasonlzy（廖子尧 Github地址：https://github.com/jeasonlzy0216
 * 版    本：1.0
 * 创建日期：2016/5/19
 * 描    述：文档选择的入口类
 * 修订历史：
 * ================================================
 */
public class DocumentPicker {

    public static final String EXTRA_DOCUMENT_ITEMS = "extra_document_items";

    private ArrayList<Document> mSelectedDocuments = new ArrayList<>();   //选中的文档集合
    private List<String> mSelectedPaths = new ArrayList<>();   //选中的文档集合

    private static volatile DocumentPicker mInstance;

    private DocumentPicker() {
    }

    public static DocumentPicker getInstance() {
        if (mInstance == null) {
            synchronized (DocumentPicker.class) {
                if (mInstance == null) {
                    mInstance = new DocumentPicker();
                }
            }
        }
        return mInstance;
    }

    public void addSelectedDocumentItem(boolean isAdd, Document item) {
        if (isAdd) {
            mSelectedDocuments.add(item);
            mSelectedPaths.add(item.path);
        }else {
            mSelectedDocuments.remove(item);
            mSelectedPaths.remove(item.path);
        }
    }

    public ArrayList<Document> getSelectedDocuments() {
        return mSelectedDocuments;
    }

    public List<String> getSelectedPaths() {
        return mSelectedPaths;
    }

    public void clean() {
        mSelectedDocuments.clear();
        mSelectedPaths.clear();
    }
}